package com.hirsi.module.department.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 部门表
 * </p>
 *
 * @author Hirsi
 * @since 2024-03-11
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("h_department")
public class Department extends Model<Department> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 父级id，没有为0
     */
    @TableField("pid")
    private Integer pid;

    /**
     * 部门名称
     */
    @TableField("name")
    private String name;

    /**
     * 拼接起来的id
     */
    @TableField("id_splice")
    private String idSplice;

    /**
     * 拼接起来的name
     */
    @TableField("name_splice")
    private String nameSplice;

    /**
     * 排序码，同级别不能重复
     */
    @TableField("sort_num")
    private Integer sortNum;

    /**
     * 创建人id
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private Integer createBy;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 最后更新人id
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private Integer updateBy;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 乐观锁字段
     */
    @TableField("version")
    @Version
    private Integer version;

    /**
     * 逻辑删除字段：0-未删除，null-已删除
     */
    @TableField("deleted")
    @TableLogic
    private Boolean deleted;

    @Override
    public Serializable pkVal() {
        return this.id;
    }
}
